<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Amaze UI Admin index Examples</title>
    <meta name="description" content="这是一个 index 页面">
    <meta name="keywords" content="index">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="icon" type="image/png" href="${ctx}/resource/amazeuiadmin/assets/i/favicon.png">
    <link rel="apple-touch-icon-precomposed" href="${ctx}/resource/amazeuiadmin/assets/i/app-icon72x72@2x.png">
    <meta name="apple-mobile-web-app-title" content="Amaze UI" />
    <link rel="stylesheet" href="${ctx}/resource/amazeuiadmin/assets/css/amazeui.min.css" />
    <link rel="stylesheet" href="${ctx}/resource/amazeuiadmin/assets/css/amazeui.datatables.min.css" />
    <link rel="stylesheet" href="${ctx}/resource/amazeuiadmin/assets/css/app.css">
    <link rel="stylesheet" href="${ctx}/resource/validationengine/css/validationEngine.jquery.css">
    <script src="${ctx}/resource/amazeuiadmin/assets/js/jquery.min.js"></script>
    <script type="text/javascript" src="${ctx}/resource/validationengine/js/jquery.validationEngine-zh_CN.js"></script>
	<script type="text/javascript" src="${ctx}/resource/validationengine/js/jquery.validationEngine.js"></script>

</head>
<body data-type="login" onkeydown="keyLogin();">
    <script src="${ctx}/resource/amazeuiadmin/assets/js/theme.js"></script>
    <div class="am-g tpl-g">
        <!-- 风格切换 -->
        <div class="tpl-skiner">
            <div class="tpl-skiner-toggle am-icon-cog">
            </div>
            <div class="tpl-skiner-content">
                <div class="tpl-skiner-content-title">
                    选择主题
                </div>
                <div class="tpl-skiner-content-bar">
                    <span class="skiner-color skiner-white" data-color="theme-white"></span>
                    <span class="skiner-color skiner-black" data-color="theme-black"></span>
                </div>
            </div>
        </div>
        <div class="tpl-login">
            <div class="tpl-login-content">
                <div class="tpl-login-logo">
                </div>
                <form class="am-form tpl-form-line-form" id="loginForm">
                    <div class="am-form-group">
                        <input type="text" class="tpl-form-input validate[required]" id="username" name="username" placeholder="请输入账号">
                    </div>
                    <div class="am-form-group">
                        <input type="password" class="tpl-form-input validate[required,minSize[6],maxSize[24]]" id="password" name="password" placeholder="请输入密码">
                    </div>
                    <div class="am-form-group tpl-login-remember-me">
                        <input id="remember-me" type="checkbox" name="remember" value="1">
                        <label for="remember-me">
                        记住密码
                         </label>
                    </div>
                    <div class="am-form-group">
                        <button id="loginBtn" type="button" class="am-btn am-btn-primary  am-btn-block tpl-btn-bg-color-success  tpl-login-btn">提交</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <script src="${ctx}/resource/amazeuiadmin/assets/js/amazeui.min.js"></script>
    <script src="${ctx}/resource/layer/layer.js"></script>
    <script src="${ctx}/resource/amazeuiadmin/assets/js/app.js"></script>
	<script type="text/javascript">
	function keyLogin(){  
		if (event.keyCode==13){//回车键的键值为13  
			//调用登录按钮的登录事件 
			$("#loginBtn").click();
		}    
	}
	
	$(function() {
		var loginForm = $('#loginForm');
		loginForm.validationEngine('attach'); 
		$("#loginBtn").click(function(){
			if(loginForm.validationEngine('validate')){
				$.getJSON('${ctx!}/admin/login',loginForm.serialize(),function(data){
					if(data.isSuccess){
						layer.msg(data.msg,{
							 icon: 1,
							 time: 1000 //1秒关闭（如果不配置，默认是3秒）
						}, function(){
							window.location.href = "${ctx!}/admin/index";
						});
					}else{
						layer.msg(data.msg,{icon:2});
					}				
				});
			}
		});
	});
	
	</script>
</body>

</html>